package com.medusa.aps.business.model.enums;

import com.alibaba.fastjson2.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;


/**
 * 制造策略枚举
 * MTS库存式生产
 * MTO订单式生产
 */
@Getter
public enum ManufacturingStrategy {

    /**
     * MTS库存式生产
     */
    MTS(1, "MTS"),

    /**
     * MTO订单式生产
     */
    MTO(2, "MTO"),
    ;


    @EnumValue
    private final Integer value;

    @JSONField(value = true)
    private final String desc;

    ManufacturingStrategy(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static ManufacturingStrategy getByValue(Integer value) {
        for (ManufacturingStrategy type : ManufacturingStrategy.values()) {
            if (type.value.equals(value)) {
                return type;
            }
        }
        return null;
    }

    public static ManufacturingStrategy getByDesc(String desc) {
        for (ManufacturingStrategy type : ManufacturingStrategy.values()) {
            if (type.desc.equals(desc)) {
                return type;
            }
        }
        return null;
    }

}

